#ifndef IMAGEINSTANCE
#define IMAGEINSTANCE

#include <QExplicitlySharedDataPointer>
#include "imageinstancedata.h"
class DicomImage;

class ImageInstance
{
public:
    ImageInstance(const QString &file):
        d(new ImageInstanceData(file)){}
    ImageInstance(DcmFileFormat *dff):
        d(new ImageInstanceData(dff)) {}
    ImageInstance(const ImageInstance &image):
        d(image.d){}

    void setWindow(const double &center, const double &width)
    { d->setWindow(center, width); }
    void getWindow(double &center, double &width) const
    { d->getWindow(center, width); }
    void setWindowDelta(const double &dCenter, const double &dWidth)
    { d->setWindowDelta(dCenter, dWidth); }
    void setRoiWindow(const QRectF &rect)
    { d->setRoiWindow(rect); }
    void setDefaultWindow() { d->setDefaultWindow(); }
    void setFullDynamic() { d->setFullDynamic(); }
    void setPolarity(EP_Polarity p) { d->setPolarity(p); }
    EP_Polarity getPolarity() const { return d->getPolarity(); }
    QString getStudyUid() const { return d->getStudyUid(); }
    QString getSeriesUid() const { return d->getSeriesUid(); }
    QString getImageUid() const { return d->getImageUid(); }
    QString getClassUid() const { return d->getClassUid(); }
    QString getImageFile() const { return d->getImageFile(); }

    bool getPixmap(QPixmap &pixmap) { return d->getPixmap(pixmap); }
    static bool getPixmap(const QString &file, QPixmap &pixmap)
    { return ImageInstanceData::getPixmap(file, pixmap); }
    static bool dcm2bmpHelper(DicomImage &image, QPixmap &pixmap)
    { return ImageInstanceData::dcm2bmpHelper(image, pixmap); }

    bool isNormal() const { return d->isNormal(); }

    DicomImage *createClippedImage(const QRect &rect, int angle = 0, bool hflip = false, bool vflip = false, bool inverted = false)
    { return d->createClippedImage(rect, angle, hflip, vflip, inverted); }
    QString getTagKeyValue(const DcmTagKey &key) const { return d->getTagKeyValue(key); }
    uint getPixelValue(long x, long y) const
    { return d->getPixelValue(x, y); }
    bool getPixSpacing(double &spacingX, double &spacingY) const
    { return d->getPixSpacing(spacingX, spacingY); }
    bool getImageSize(ulong &width, ulong &height) const
    { return d->getImageSize(width, height); }
    const short *getInternalPtr() const
    { return d->getInternalPtr(); }
    const ushort *getRawData() const
    { return d->getRawData(); }

    const DicomImage *getDcmImage() const { return d->getDcmImage(); }
    DcmFileFormat *getFileFormat() { return d->getFileFormat(); }
    bool saveFileFormat() { return d->saveFileFormat(); }

private:
    QExplicitlySharedDataPointer<ImageInstanceData> d;
};

Q_DECLARE_TYPEINFO(ImageInstance, Q_MOVABLE_TYPE);

#endif // IMAGEINSTANCE
